<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <% 
String path=request.getContextPath();
pageContext.setAttribute("path", path);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>无标题文档</title>
    <link href="${path }/admin/css/tail.css" rel="stylesheet" type="text/css">
    <link href="${path }/admin/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
.w-e-toolbar{
  flex-wrap:wrap;
}

</style>
</head>
<body style="border-radius: 8px;width: 900px">
<form  action="${path }/AdminAddArticleServlet" method="get">
<div class="top">
    <div>
        <div class="top_out">
            <table class="table">
                <tbody>
                <tr>
                    <td>标题<span>*</span></td>
                    <td colspan = "8" ><input type="text" name="title" class="frist_input" placeholder="请输入标题"  minlength="2"  required  ></td>
                </tr>
                
                <tr> 
                    <td>文章内容<span>*</span></td>
                    
                    <td colspan = "8" >
                    <div  id="div1">
									
					</div>
					<textarea name="content" id="wang" style="width:100%; height:200px;" class="form__textarea"></textarea>
					</td>
                </tr>
                <tr>
                    <td>类别<span>*</span></td>
                    <td>
                        <div class="form__select-wrap">
										<select name="catalogs" id="category" class="form__select">
											<option value="0"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">第1类</font></font></option>
											<option value="1"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">2类</font></font></option>
											<option value="2"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">第3类</font></font></option>
										</select>
									</div>
                    </td>
                    
                </tr>
                <tr>
                    <td>封面<span>*</span></td>
                    <td>
                        <input type="text" name="cover" placeholder="" required  maxlength ="10">
                    </td>
                    
                </tr>
                <tr>
                    <td>作者<span>*</span></td>
                    <td>
                        <input type="text" name="userinfo" placeholder="" required  maxlength ="10">
                    </td>
                    
                </tr>
                <tr>
                    <td>时间<span>*</span></td>
                    <td>
                        <input type="text" name="posttime" placeholder="" required  maxlength ="10">
                    </td>
                    
                </tr>
                <tr>
                    <td>评论<span>*</span></td>
                    <td>
                        <input type="text" name="review" placeholder="" required  maxlength ="10">
                    </td>
                    
                </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div class="notice_bot">
        <div class="l_left"><input type="checkbox" checked="checked"/>保存并关闭窗口</div>
        <div class="r_right but_p"><button class="but_save" onclick="save()">保存</button><button class="but_close"  onclick="Cancel()">关闭</button></div>
    </div>
</div>
</form>
</body>
<script src="${path }/admin/js/jquery/jQuery-2.2.0.min.js"></script>
<script src="${path }/admin/js/utf8-php/ueditor.config.js"></script>
<script src="${path }/admin/js/utf8-php/ueditor.all.min.js"></script>
<script src="${path }/admin/js/layer_v2.1/layer/layer.js"></script>
<script src="${path }/admin/js/common.js"></script>
<script>
    function Cancel() {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }
    function save() {
        alert("保存成功",Cancel)
    }
</script>
<script >
    var ue = UE.getEditor('editor');
    function isFocus(e){
        alert(UE.getEditor('editor').isFocus());
        UE.dom.domUtils.preventDefault(e)
    }
    function setblur(e){
        UE.getEditor('editor').blur();
        UE.dom.domUtils.preventDefault(e)
    }
    function insertHtml() {
        var value = prompt('????html????', '');
        UE.getEditor('editor').execCommand('insertHtml', value)
    }
    function createEditor() {
        enableBtn();
        UE.getEditor('editor');
    }
    function getAllHtml() {
        alert(UE.getEditor('editor').getAllHtml())
    }
    function getContent() {
        var arr = [];
        arr.push("");
        arr.push("");
        arr.push(UE.getEditor('editor').getContent());
        alert(arr.join("\n"));
    }
    function getPlainTxt() {
        var arr = [];
        arr.push("");
        arr.push("");
        arr.push(UE.getEditor('editor').getPlainTxt());
        alert(arr.join('\n'))
    }
    function setContent(isAppendTo) {
        var arr = [];
        arr.push("");
        UE.getEditor('editor').setContent('??????ueditor', isAppendTo);
        alert(arr.join("\n"));
    }
    function setDisabled() {
        UE.getEditor('editor').setDisabled('fullscreen');
        disableBtn("enable");
    }

    function setEnabled() {
        UE.getEditor('editor').setEnabled();
        enableBtn();
    }

    function getText() {

        var range = UE.getEditor('editor').selection.getRange();
        range.select();
        var txt = UE.getEditor('editor').selection.getText();
        alert(txt)
    }

    function getContentTxt() {
        var arr = [];
        arr.push("");
        arr.push("");
        arr.push(UE.getEditor('editor').getContentTxt());
        alert(arr.join("\n"));
    }
    function hasContent() {
        var arr = [];
        arr.push("");
        arr.push("");
        arr.push(UE.getEditor('editor').hasContents());
        alert(arr.join("\n"));
    }
    function setFocus() {
        UE.getEditor('editor').focus();
    }
    function deleteEditor() {
        disableBtn();
        UE.getEditor('editor').destroy();
    }
    function disableBtn(str) {
        var div = document.getElementById('btns');
        var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            if (btn.id == str) {
                UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
            } else {
                btn.setAttribute("disabled", "true");
            }
        }
    }
    function enableBtn() {
        var div = document.getElementById('btns');
        var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
        }
    }

    function getLocalData () {
        alert(UE.getEditor('editor').execCommand( "getlocaldata" ));
    }

    function clearLocalData () {
        UE.getEditor('editor').execCommand( "clearlocaldata" );
        alert("")
    }
</script>
<script type="text/javascript" src="${path}/static/jsp/wangEditor/wangEditor.js"></script>
<script type="text/javascript">
        var E = window.wangEditor
        var editor = new E('#div1')
        var $wang = $('#wang')
        editor.customConfig.onchange = function (html) {
            // 监控变化，同步更新到 textarea
            $wang.val(html)
        }
        editor.customConfig.uploadImgServer = '${path}/FileServlet'
        editor.create()
        // 初始化 textarea 的值
        $wang.val(editor.txt.html())
    </script>
</html>